# Contributor: ProgCat <progcat@protonmail.com>
# Maintainer: ProgCat <progcat@protonmail.com>
pkgname=fcitx5-chewing
pkgver=5.1.0
pkgrel=0
pkgdesc="Chewing Wrapper for Fcitx"
url="https://github.com/fcitx/fcitx5-chewing"
arch="all !armhf"
license="LGPL-2.1-or-later"
makedepends="
	cmake
	extra-cmake-modules
	fcitx5-dev
	gettext-dev
	libchewing-dev
	samurai
	"
subpackages="$pkgname-lang"
source="$pkgname-$pkgver.tar.gz::https://github.com/fcitx/fcitx5-chewing/archive/refs/tags/$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
ec090f752e0033b46a179fda730a7578e3230cedea0e795eddeb148523f8b9a776a075aedab19be65b8dae51ebc0a6de6eba567fe4b65b89e74703cb742137c7  fcitx5-chewing-5.1.0.tar.gz
"
